package com.springapp.web;

import com.springapp.domain.Job;
import com.springapp.service.JobService;
import com.springapp.util.PageResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;


/**
 * 功能概要：JobController
 * <p/>
 * Created by 雪峰 on 2016/5/7.
 */
@Controller
public class JobController extends BaseController {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Resource
    private JobService jobService;

    @RequestMapping("/")
    public String getIndex() {
        return "index";
    }

    @RequestMapping(value = "/webcontent/page/jobPage/list.do", method = RequestMethod.POST)
    @ResponseBody
    public String list(Integer pageNumber, Integer pageSize, String job) {
        logger.info("分页查询职位信息请求列表入参：pageNumber{},pageSize{}", pageNumber, pageSize);
        try {
            PageResult<Job> pageResult = jobService.queryByPage(job, pageNumber, pageSize);
            return responseSuccess(pageResult);
        } catch (Exception e) {
            return responseFail(e.getMessage());
        }
    }

}
